<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>点赞的效果</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        /* 
        brew services start nginx 
        brew services stop nginx 
        */
        .heart{
            position:absolute;
            left: 50%;
            top:50%;
            margin-left: -150px;
            margin-top: -135px;
            width: 300px;
            height:300px;
            background: transparent;
            animation: test 1s linear 1;
            filter:drop-shadow(0px 0px 4px rgb(192,192,192));
        }
        .heart-red {
            position:absolute;
            left: 50%;
            top:50%;
            margin-left: -150px;
            margin-top: -135px;
            width: 300px;
            height:300px;
            background: transparent;
            animation: test 1s linear 1;
            filter:drop-shadow(0px 0px 4px rgb(255,20,20));
        }
        .heart:before,
        .heart:after {
            content: "";
            position: absolute;
            left: 150px;
            width: 150px;
            height: 240px;
            background: rgb(192,192,192);
            border-radius: 150px 150px 0 0;
            transform:rotate(-45deg);
            transform-origin: 0 100%;
        }
        .heart-red:before,.heart-red:after{
            content: "";
            position: absolute;
            left: 150px;
            width: 150px;
            height: 240px;
            background: rgb(255,0,0);
            border-radius: 150px 150px 0 0;
            transform:rotate(-45deg);
            transform-origin: 0 100%;
        }
        .heart:after,.heart-red:after{
            left: 0;
            transform:rotate(45deg);
            transform-origin: 100% 100%;
        }
        @keyframes test {
            0%{
                /* transform: scale(0.8,0.8); */
                opacity: 0.8;
            }
            50%{
                transform: scale(1.1,1.1);
                opacity: 1;
            }
            100%{
                transform: scale(1,1);
                opacity: 0.8;
            }
        }
    </style>
</head>
<body>
<div id="heart" class="heart" >
</div>
<div id="heart-red" class="heart-red" style="display: none;">
</div>
<script>
    document.getElementById("heart").addEventListener("click", function() {
        document.getElementById("heart-red").style.display = "block";
        this.style.display = "none";
    });
    document.getElementById("heart-red").addEventListener("click", function(){
        document.getElementById("heart").style.display = "block";
        this.style.display = "none";
    });
</script>
</body>
</html>